/*
 * This class implements a performance tester for files in the iNode file system
 */

#ifndef INODEPREF_H
#define INODEPREF_H

#include <vector>

#include "SingleFilePref.h"


class INodePref : public SingleFilePref {

private:

	//Functions

	//Given an arrangement of pointers, the function returns maximal file size it can represent
	double getCurrentMaxFileSize(std::vector<int>& pointers,unsigned int blockSize,
			float blockPtrRatio);

	//This function rearrange the pointers in a header by reducing the direct pointers
	//and adding another indirect pointer of some level
	std::vector<int> reduceBlocksArray(std::vector<int>& pointers, int maxSize);

	//This function returns the optimal pointer arrangement for the header representing the file
	//in the file system
	std::vector<int> getHeaderArrangement(unsigned int maximalSize,unsigned int blockSize,
			float blockPtrRatio,std::vector<int> pointers);

	int isMaximalSizeOk();

	//Data Members

	//Symbolizes the direct and indirect pointer arrangement
	std::vector<int> _headerArrangement;


public:

	//Functions

	//Constructor
	INodePref(unsigned int maximalSize, unsigned int blockSize,unsigned int pointerSize);

	//Assigns to output the space and average accesses to memory for the specific fileSize.
	//If all goes well, SUCCESS is the return value, FAILURE otherwise
	virtual int singleFileSystemPerformance(unsigned int fileSize,outputStruct *output);

	//The function make sure the maximal file size given to the class can be represented under
	//the constraints it has
	virtual int areConstraintsPossilble();

};

#endif
